<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="/user/js/jquery.min.js"></script>
    <script>
        function getParams() {
            //获取问号后面的值
            let url = location.search;
            //声明一个对象
            let obj = null;
            //解析url参数
            if (url.indexOf("?") != -1) {
                obj = new Object();
                url = url.substr(1);
                let ids = url.split("&");
                for (let i = 0; i < ids.length; i++) {
                    obj[ids[i].split("=")[0]] = decodeURIComponent(ids[i].split("=")[1]);
                }
            }

            return obj;
        }


        let index = "http://localhost:9003/user/showregister";

        $(function () {
            if ( getParams() != null) {
                index = getParams()["server"];
            }
            console.log(getParams());

            $("#login-button").click(() => {
                $.post("http://192.168.2.18:9003/user/userserver/login", $("#login-form").serialize(), rs => {
                    if (rs.status == 200) {
                        console.log(index);
                        location.href = index;

                    }
                });
            });

        })
    </script>
</head>
<body>
<form action="http://localhost:9003/user/userserver/login" method="post" id="login-form">
    <label>用户名:</label><input type="text" name="username"/><br/>
    <label>密码:</label><input type="password" name="password"/><br/>
    <button type="button" id="login-button">提交</button>
</form>
</body>
</html>